package com.jsu.service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.jsu.bean.Lost;
import com.jsu.bean.LostDetail;
import com.jsu.bean.LostExample;
import com.jsu.bean.LostExample.Criteria;
import com.jsu.bean.LostMessage;
import com.jsu.bean.LostMessageExample;
import com.jsu.dao.LostMapper;
import com.jsu.dao.LostMessageMapper;

@Component
public class GetMyLostService {

	@Autowired
	LostMapper lostMapper;
	@Autowired
	LostMessageMapper lostMessageMapper;
	
	public List<LostDetail> getMyLost(Integer id) {
		List<LostDetail> lostDetails = new ArrayList<LostDetail>();
		LostExample lostExample = new LostExample();
		com.jsu.bean.LostExample.Criteria criteria1 = lostExample.createCriteria();
		criteria1.andPersonEqualTo(id);
		List<Lost> losts = lostMapper.selectByExample(lostExample);
		for(Lost lost:losts){
			
			List<LostMessage> lostMessages = lostMessageMapper.selectByLost(lost.getLostId());
			LostDetail lostDetail = new LostDetail();
			lostDetail.setLost(lost);
			lostDetail.setLostMessages(lostMessages);
			lostDetails.add(lostDetail);
		}
		return lostDetails;
	}

}
